import re

namespace = "https://docs.google.com/"

transformers = [
        ("a/([^/]*)/document/d/([^/]*)/edit.*",
         lambda m: namespace + "document/export?format=odt&id=" + m.group(2)),
        ("a/([^/]*)/presentation/d/([^/]*)/edit.*",
         lambda m: namespace + "presentation/d/" + m.group(2) + "/export/odp")
]

def transform(URL):
    for trans in transformers:
        URL = re.sub(namespace + trans[0], trans[1], URL)

    return URL
